package com.hjx.service.impl;

import com.hjx.entity.SysRole;
import com.hjx.mapper.SysRoleMapper;
import com.hjx.service.SysRoleService;
import com.hjx.util.UUIDUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * <p>Title:</p>
 * <p>Description:</p>
 *
 * @author hjx
 * @date 2020/6/16 - 16:08
 */
@Service
@Transactional
public class SysRoleServiceImpl implements SysRoleService {
    @Resource
    SysRoleMapper sysRoleMapper;

    @Override
    public SysRole findOne(String rid) {
        if (!StringUtils.isEmpty(rid) && !StringUtils.isBlank(rid)) {
            return sysRoleMapper.findOne(rid);
        }
        return null;
    }

    @Override
    public List<SysRole> findAll() {
        return sysRoleMapper.findAll();
    }

    @Override
    public List<SysRole> findAllRoleAndMenu() {
        return sysRoleMapper.findAllRoleAndMenu();
    }

    @Override
    public boolean insert(SysRole sysRole) {
        sysRole.setRid(UUIDUtil.getUUID());
        return sysRoleMapper.insert(sysRole);
    }

    @Override
    public boolean insertBatch(SysRole[] roles) {
        return sysRoleMapper.insertBatch(roles);
    }

    @Override
    public boolean update(SysRole sysRole) {
        return sysRoleMapper.update(sysRole);
    }

    @Override
    public boolean delete(String rid) {
        if (!StringUtils.isEmpty(rid) && !StringUtils.isBlank(rid)) {
            return sysRoleMapper.delete(rid);
        }
        return false;
    }
}
